home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9048 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: dispatch.news.demon.net!demon!vecnet
  2. From: gspencer@vecnet.demon.co.uk (Gary K. Spencer)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: templates on VAX/VMS
  5. Date: Wed, 28 Feb 1996 08:41:55 GMT
  6. Organization: Vector Networks Limited
  7. Message-ID: <825496915.10116@vecnet.demon.co.uk>
  8. References: <gastineau-2502961624010001@dialupline64.ghgcorp.com>
  9. NNTP-Posting-Host: vecnet.demon.co.uk
  10. X-NNTP-Posting-Host: vecnet.demon.co.uk
  11. X-Newsreader: News Xpress Version 1.0 Beta #4
  12.  
  13. In article <gastineau-2502961624010001@dialupline64.ghgcorp.com>,
  14.    gastineau@ghgcorp.com (Brian Gastineau) wrote:
  15. >I am trying to implement a linked list template out of the "C++ How to
  16. >Program" textbook by Deitel & Deitel, 1994, page 697, on a VAX.
  17. >
  18. >The node template class is of the form:
  19. >
  20. >   template<class NODETYPE>
  21. >   class ListNode {
  22. >      friend class List<NODETYPE>;
  23. >   public:
  24. >      ListNode(const NODETYPE &);
  25. >      NODETYPE getData() const;
  26. >   private:
  27. >      NODETYPE data;
  28. >      ListNode *nextPtr;
  29. >   };
  30. >
  31. >The list template class is of the form:
  32. >
  33. >   template<class NODETYPE>
  34. >   class List {
  35. >   public:
  36. >      List();
  37. >      ~List();
  38. >      void insertAtFront(const NODETYPE &);
  39. >      void insertAtBack(const NODETYPE &);
  40. >      int removeFromFront(NODETYPE &);
  41. >      int removeFromBack(NODETYPE &);
  42. >      int isEmpty() const;
  43. >      void print() const;
  44. >   private:
  45. >     ListNode<NODETYPE> *firstPtr;
  46. >       ListNode<NODETYPE> *lastPtr;
  47. >      ListNode<NODETYPE> *getNewNode(const NODETYPE &);
  48. >   };
  49. >
  50. >All of the object function declaration have a related function body
  51. >included in the same file.  I've got some subroutines in other files that
  52. >are compiling and linking OK, so I don't think that the problem lies with
  53. >not including the files in the right way
  54. >
  55. >The driver uses the templates in the following lines:
  56. >
  57. >   List<int> integerList;
  58. >   List<float> floatList;
  59. >
  60. >The code compiles OK, but during linking, the following errors are given:
  61. >
  62. >   $ link driver
  63. >   %LINK-W-NUDFSYMS, 14 undefined symbols:
  64. >   %LINK-I-UDFSYM,         INSERTATBACK__8LIST___FXNKF
  65.  
  66. You need to use :-
  67.     #pragma define_template List<int>
  68.     #pragma define_template List<float>
  69.  
  70. in one of your source modules to get the compiler to generate the code for the 
  71. template class. I think there is a command line switch that does the same 
  72. thing, but I use the above method.
  73.  
  74. Regards
  75.  
  76. Gary K. Spencer
  77. Vector Networks Limited
  78.  
  79.     
  80.